using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace HLSSignature
{
    internal partial class SignatureSetupForm : Form, IDisposable
    {
        public bool success = false;
        private Microsoft.Office.Core.SignatureSetup sigsetup = null;



        public SignatureSetupForm(Microsoft.Office.Core.SignatureSetup sigsetup)
        {
            this.sigsetup = sigsetup;
            InitializeComponent();
        }

        private void SignatureSetup_Load(object sender, EventArgs e)
        {
            bool readOnly = this.sigsetup == null || this.sigsetup.ReadOnly;

            this.txtbxSuggSignerName.Enabled = !readOnly;
            this.txtbxSuggSignerTitle.Enabled = !readOnly;
            this.txtbxSuggSignerEmail.Enabled = !readOnly;
            this.chkbxAllowComments.Enabled = !readOnly;
            this.txtInstruction.Enabled = !readOnly;
            this.btnOK.Enabled = !readOnly;
                
            //this.lblSafeDisclaimer.Text = this.SAFEDisclaimer;
            this.lblSafeDisclaimer.Text = SAFEImage.SAFEDisclaimer;

            if (this.sigsetup != null)
            {
            
                this.txtbxSuggSignerName.Text = this.sigsetup.SuggestedSigner;
                this.txtbxSuggSignerTitle.Text = this.sigsetup.SuggestedSignerLine2;
                this.txtbxSuggSignerEmail.Text = this.sigsetup.SuggestedSignerEmail;
                this.chkbxAllowComments.Checked = this.sigsetup.AllowComments;
                this.txtInstruction.Text = this.sigsetup.SigningInstructions;
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.sigsetup == null || this.sigsetup.ReadOnly)
                throw new InvalidOperationException();
            this.sigsetup.AdditionalXml = SAFEImage.SAFEDisclaimer;
            this.sigsetup.SigningInstructions = this.txtInstruction.Text;
            this.sigsetup.SuggestedSigner = this.txtbxSuggSignerName.Text;
            this.sigsetup.SuggestedSignerLine2 = this.txtbxSuggSignerTitle.Text;
            this.sigsetup.SuggestedSignerEmail = this.txtbxSuggSignerEmail.Text;
            this.sigsetup.AllowComments = this.chkbxAllowComments.Checked;
           // this.sigsetup.SigningInstructions = this.txtInstruction.Text;
          

            this.success = true;
            this.Close();
        }
    }
}